import java.util.HashMap;
import java.util.Map;

public class project {
    public String makeFancyString(String s) {
        StringBuilder sb=new StringBuilder();
        if(s.length()<3){
            return s;
        }
        int count=1;
        char ch=s.charAt(0);
        sb.append(ch);
        for(int i=1;i<s.length();i++){
            if(ch!=s.charAt(i)){
                sb.append(s.charAt(i));
                count=1;
                ch=s.charAt(i);
            }else if(count<2){
                sb.append(s.charAt(i));
                count++;
            }
        }
        return sb.toString();
    }









    public String reformatDate(String date) {
        String[] month=new String[]{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
        String[] str=date.split(" ");
        String s=str[2]+"-";
        for(int i=0;i<month.length;i++){
            if(month[i].equals(str[1])){
                if(i<9){
                    s=s+"0"+(i+1);
                }else{
                    s=s+(i+1);
                }
            }
        }
        String day=str[0].substring(0,str[0].length()-2);
        return s+"-"+(day.length()>1?day:"0"+day);
    }










    public boolean checkStraightLine(int[][] coordinates) {
        int x1=coordinates[1][1]-coordinates[0][1];
        int y1=coordinates[1][0]-coordinates[0][0];
        for(int i=0;i<coordinates.length;i++){
            int x2=coordinates[i][1]-coordinates[0][1];
            int y2=coordinates[i][0]-coordinates[0][0];
            if(x1*y2!=y1*x2){
                return false;
            }
        }
        return true;
    }










    public int daysBetweenDates(String date1, String date2) {
        return Math.abs(toDay(date1)-toDay(date2));
    }
    public int toDay(String s){
        String[] str=s.split("-");
        int year=Integer.parseInt(str[0]);
        int month=Integer.parseInt(str[1]);
        int day=Integer.parseInt(str[2]);
        if(month<=2){
            year--;
            month+=10;
        }else{
            month-=2;
        }
        return 365*year+year/4-year/100+year/400+30*month+(3*month-1)/5+day;
    }













    public char slowestKey(int[] releaseTimes, String keysPressed) {
        int max=releaseTimes[0];
        for(int i=releaseTimes.length-1;i>0;i--){
            releaseTimes[i]=releaseTimes[i]-releaseTimes[i-1];
            max=Math.max(max,releaseTimes[i]);
        }
        char ch='a';
        for(int i=0;i<keysPressed.length();i++){
            if(releaseTimes[i]==max){
                ch=ch<keysPressed.charAt(i)?keysPressed.charAt(i):ch;
            }
        }
        return ch;
    }












    public int maxLengthBetweenEqualCharacters(String s) {
        int max=-1;
        Map<Character,Integer> map=new HashMap<>();
        for(int i=0;i<s.length();i++){
            if(map.get(s.charAt(i))==0){
                map.put(s.charAt(i),i);
            }else{
                max=Math.max(i-map.get(s.charAt(i))-1,max);
            }
        }
        return max;
    }
}
